<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
	//前台首页
    public function index()
    {
    	//print_r($_SESSION);
        //公共显示变量
        $this->public_xianshi();

        //年级
        $grades = M('grade')->where(array('parent_id'=>0))->select();
        $this->assign('grades',$grades);
        //科目
        $kemus = M('subjects')->select();
        $this->assign('kemus',$kemus);


        //高考 高中 取4条
        $gaokao = M('grade')->where(array('parent_id'=>4))->limit(4)->select();
        $this->assign('gaokao',$gaokao);
        //高一
        $gaoyi = M('grade')->where(array('parent_id'=>3))->select();
        $this->assign('gaoyi',$gaoyi);
        //高二
        $gaoer = M('grade')->where(array('parent_id'=>2))->select();
        $this->assign('gaoer',$gaoer);
        //高三
        $gaosan = M('grade')->where(array('parent_id'=>1))->select();
        $this->assign('gaosan',$gaosan);
        //高考
        $gaokaos = M('grade')->where(array('parent_id'=>4))->select();
        $this->assign('gaokaos',$gaokaos);

        //中考 初中 取4条
        $zhongkao = M('grade')->where(array('parent_id'=>8))->limit(4)->select();
        $this->assign('zhongkao',$zhongkao);
        //初一
        $chuyi = M('grade')->where(array('parent_id'=>7))->select();
        $this->assign('chuyi',$chuyi);
        //初二
        $chuer = M('grade')->where(array('parent_id'=>6))->select();
        $this->assign('chuer',$chuer);
        //初三
        $chusan = M('grade')->where(array('parent_id'=>5))->select();
        $this->assign('chusan',$chusan);
        //中考
        $zhongkaos = M('grade')->where(array('parent_id'=>8))->select();
        $this->assign('zhongkaos',$zhongkaos);

        //小升初 小学 取3条
        $xiaokao = M('grade')->where(array('parent_id'=>9))->limit(3)->select();
        $this->assign('xiaokao',$xiaokao);
        //一年级
        $xiaoyi = M('grade')->where(array('parent_id'=>15))->select();
        $this->assign('xiaoyi',$xiaoyi);
        //二年级
        $xiaoer = M('grade')->where(array('parent_id'=>14))->select();
        $this->assign('xiaoer',$xiaoer);
        //三年级
        $xiaosan = M('grade')->where(array('parent_id'=>13))->select();
        $this->assign('xiaosan',$xiaosan);
        //四年级
        $xiaosi = M('grade')->where(array('parent_id'=>12))->select();
        $this->assign('xiaosi',$xiaosi);
        //五年级
        $xiaowu = M('grade')->where(array('parent_id'=>11))->select();
        $this->assign('xiaowu',$xiaowu);
        //六年级
        $xiaoliu = M('grade')->where(array('parent_id'=>10))->select();
        $this->assign('xiaoliu',$xiaoliu);

        //艺术兴趣 id=48  取3条
        $yishu = M('grade')->where(array('parent_id'=>48))->order('gradeid')->limit(3)->select();
        $this->assign('yishu',$yishu);
        //艺术兴趣 id=48 
        $tskc = M('grade')->where(array('parent_id'=>48))->order('gradeid')->select();
        $this->assign('tskc',$tskc);

        //留学语言 id=116 取3条
        $liuxue = M('grade')->where(array('parent_id'=>116))->limit(3)->select();
        $this->assign('liuxue',$liuxue);
        //留学语言 id=116 
        $lxyy = M('grade')->where(array('parent_id'=>116))->select();
        $this->assign('lxyy',$lxyy);

        //高中
        //自动获取城市 高中数学 取最多5条
        $city_info = I('get.newcity')?I('get.newcity'):'广州';
        
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '1|2|3|4' and t1.city='{$city_info}' and t3.subject='数学' order by t1.create_time desc limit 5";
        $sx = M()->query($sql);
        $this->assign('sx',$sx);

         //自动获取城市 高中语文 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '1|2|3|4' and t1.city='{$city_info}' and t3.subject='语文' order by t1.create_time desc limit 5";
        $yw = M()->query($sql);
        $this->assign('yw',$yw);

         //自动获取城市 高中英语 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '1|2|3|4' and t1.city='{$city_info}' and t3.subject='英语' order by t1.create_time desc limit 5";
        $yy = M()->query($sql);
        $this->assign('yy',$yy);

         //自动获取城市 高中物理 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '1|2|3|4' and t1.city='{$city_info}' and t3.subject='物理' order by t1.create_time desc limit 5";
        $wl = M()->query($sql);
        $this->assign('wl',$wl);

         //自动获取城市 高中化学 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '1|2|3|4' and t1.city='{$city_info}' and t3.subject='化学' order by t1.create_time desc limit 5";
        $hx = M()->query($sql);
        $this->assign('hx',$hx);

        // 初中
        //自动获取城市 初中数学 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '5|6|7|8' and t1.city='{$city_info}' and t3.subject='数学' order by t1.create_time desc limit 5";
        $cz_sx = M()->query($sql);
        $this->assign('cz_sx',$cz_sx);

         //自动获取城市 初中语文 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '5|6|7|8' and t1.city='{$city_info}' and t3.subject='语文' order by t1.create_time desc limit 5";
        $cz_yw = M()->query($sql);
        $this->assign('cz_yw',$cz_yw);

         //自动获取城市 初中英语 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '5|6|7|8' and t1.city='{$city_info}' and t3.subject='英语' order by t1.create_time desc limit 5";
        $cz_yy = M()->query($sql);
        $this->assign('cz_yy',$cz_yy);

         //自动获取城市 初中物理 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '5|6|7|8' and t1.city='{$city_info}' and t3.subject='物理' order by t1.create_time desc limit 5";
        $cz_wl = M()->query($sql);
        $this->assign('cz_wl',$cz_wl);

         //自动获取城市 初中化学 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '5|6|7|8' and t1.city='{$city_info}' and t3.subject='化学' order by t1.create_time desc limit 5";
        $cz_hx = M()->query($sql);
        $this->assign('cz_hx',$cz_hx);

        //小学
        //自动获取城市 小学数学 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '9|10|11|12|13|14|15' and t1.city='{$city_info}' and t3.subject='数学' order by t1.create_time desc limit 5";
        $xx_sx = M()->query($sql);
        $this->assign('xx_sx',$xx_sx);

         //自动获取城市 初中语文 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '9|10|11|12|13|14|15' and t1.city='{$city_info}' and t3.subject='语文' order by t1.create_time desc limit 5";
        $xx_yw = M()->query($sql);
        $this->assign('xx_yw',$xx_yw);

         //自动获取城市 初中英语 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t3.grades REGEXP '9|10|11|12|13|14|15' and t1.city='{$city_info}' and t3.subject='英语' order by t1.create_time desc limit 5";
        $xx_yy = M()->query($sql);
        $this->assign('xx_yy',$xx_yy);

        //特色课程
        //自动获取城市 器乐 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t1.city='{$city_info}' and t3.subject='器乐' order by t1.create_time desc limit 5";
        $yinyue = M()->query($sql);
        $this->assign('yinyue',$yinyue);

         //自动获取城市 舞蹈 取最多5条
        $sql = "select t1.id,t1.name,t1.city,t1.face,t2.jiaoling,t2.jianjie,t3.subject,t3.price,t3.sk_city from laoshi_user as t1 inner join jiaoling_jli as t2 on t1.id=t2.uid inner join showke_info as t3 on t1.id=t3.uid where is_shenhe_xs=1 and is_dongjie=1 and is_del=0 and t1.city='{$city_info}' and t3.subject='舞蹈' order by t1.create_time desc limit 5";
        $meishu = M()->query($sql);
        $this->assign('meishu',$meishu);


        $this->display();
    }

    //家长指南
    public function jiazhang_zn()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }

    //老师指南
    public function laoshi_zn()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }

    //关于平台
    public function about()
    {
        //公共显示变量
        $this->public_xianshi();

        $this->display();
    }


}